package com.yedean.factory.io;

import java.io.File;
import java.io.InputStream;
import java.nio.file.Files;

/**
 * FileResource
 *
 * @author yedean
 * @date 2022/7/7
 */
public class FileSystemResource implements Resource{
    
    private final File file;

    private final String path;

    public FileSystemResource(File file) {
        this.file = file;
        this.path = file.getPath();
    }


    public FileSystemResource(String path) {
        this.file = new File(path);
        this.path = path;
    }


    @Override
    public InputStream getInputStream() throws Exception {
        return Files.newInputStream(file.toPath());
    }
}
